#!/bin/bash
#
# Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

# Copy desktop files to user skeleton folder.
# Do this before creating any users.
DESK_APPS=$(installer_get "dde_desktop_app_list")
if [ -n ${DESK_APPS} ]; then
  DESK_APPS_ARR=$(echo ${DESK_APPS//,/ })
  for DESK_APP_ITEM in $(echo ${DESK_APPS_ARR}); do
    msg "Copy app icon to desktop: ${DESK_APP_ITEM}"
    if [ -f /usr/share/applications/${DESK_APP_ITEM}.desktop ]; then
      install -v -Dm644 /usr/share/applications/${DESK_APP_ITEM}.desktop \
        /etc/skel/Desktop/
    else
      warn "Desktop file not found: ${DESK_APP_ITEM}"
    fi
  done
fi

return 0
